package wrapper;

public class IntegerDemo {
    public static void main(String[] args) {
        /*
        Integer i1 = new Integer(5);
        Integer i2 = new Integer(5);
        System.out.println(i1==i2);
        System.out.println(i1.equals(i2));

        Integer i3 = Integer.valueOf(5);
        Integer i4 = Integer.valueOf(5);
        System.out.println(i3==i4);
        System.out.println(i3.equals(i4));

         */
        Integer i = Integer.valueOf(5);  //基本类型转换为包装类
        int j = i.intValue();  //包装类型转换为基本类型
        Integer m = 5;  //基本类型到包装类-----装箱
        int n = m;  //包装类到基本类型---------拆箱

        int max = Integer.MAX_VALUE;
        int min = Integer.MIN_VALUE;
        System.out.println("int的最大值为："+max+",最小值为："+min);

        long maxLong = Long.MAX_VALUE;
        long minLong = Long.MIN_VALUE;
        System.out.println("long的最大值为："+maxLong+"，最小值为："+minLong);

        String s1 = "40";
        int age = Integer.parseInt(s1);  //将字符串s1串换为int类型并赋值给age
        System.out.println(age); //40---int类型

        String s2 = "123.456";
        double price = Double.valueOf(s2);  //将字符串s2转换为double类型并赋值给price
        System.out.println(price);  //123.456---double类型
    }
}
